
// <copyright file="AbstractChildUserControl.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   Defines the WebHelper type.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Web
{
    using System;
    using System.Web.UI;

    /// <summary>
    /// </summary>
    public abstract class AbstractChildUserControl : UserControl
    {
        #region Public Properties

        /// <summary>
        ///     Gets the master control.
        /// </summary>
        /// <value>
        ///     The master control.
        /// </value>
        public Control MasterControl { get; private set; }

        /// <summary>
        ///     Gets the master control virtual path.
        /// </summary>
        /// <value>
        ///     The master control virtual path.
        /// </value>
        public abstract string MasterControlVirtualPath { get; }

        #endregion Public Properties

        #region Methods

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">
        /// An <see cref="T:System.EventArgs"/> object that contains the event data.
        /// </param>
        protected override void OnInit(EventArgs e)
        {
            this.MasterControl = this.LoadControl(this.MasterControlVirtualPath);
            this.Controls.Add(this.MasterControl);

            base.OnInit(e);
        }

        /// <summary>
        /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter"/> object, which writes the
        ///     content to be rendered on the client.
        /// </summary>
        /// <param name="writer">
        /// The <see cref="T:System.Web.UI.HtmlTextWriter"/> object that receives the server control content.
        /// </param>
        protected override void Render(HtmlTextWriter writer)
        {
            this.MasterControl.RenderControl(writer);
        }

        #endregion Methods
    }
}
